<%--
  Created by IntelliJ IDEA.
  User: 18318
  Date: 2022/7/15
  Time: 15:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="${pageContext.request.contextPath}/static/echarts/echarts.js"></script>
<%@include file="../common.jsp" %>
<html>
<head>
    <title>SDS测试结果页面</title>
</head>
<body>

<%--头部工具栏--%>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger " lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
<%--行内工具栏--%>
<script type="text/html" id="rowBarDemo">
  <%--  <a class="layui-btn layui-btn-sm" lay-event="return2">回访记录</a>--%>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="check">查看结果</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="result">查看详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>

</script>
<%--查看详情的表格--%>
<form class="layui-form" action="" id="addForm" enctype="multipart/form-data" style="display: none">
    <table id="clickResult" lay-filter="test"></table>
</form>
<%--模糊查询--%>
<form class="layui-form" action="" style="margin-top: 10px">
    <div class="layui-inline">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">测试名称</label>
        <div class="layui-input-inline">
            <input type="text" name="testName" placeholder="请输入测试计划名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">学生类型</label>
        <div class="layui-input-inline">
            <select name="studentType" lay-filter="type" id="questionman">
                <option selected value="1">查询所有</option>
                <option value="2">躯体化</option>
                <option value="3">强迫</option>
                <option value="4">人际敏感</option>
                <option value="5">抑郁</option>
                <option value="6">焦虑</option>
                <option value="7">敌对</option>
                <option value="8">恐怖</option>
                <option value="9">偏执</option>
                <option value="10">精神</option>
                <option value="11">睡眠及饮食</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="selectFormfilter">查询</button>
            <button type="reset" class="layui-btn layui-btn-primary" id="myButton">重置</button>
        </div>
    </div>
</form>
<style>
    #show {
        /*width: 600px;*/
        /*height: 800px;*/
        /*border: 4px solid cornflowerblue;*/
        margin: auto;

        background: #C2BE9E;
        font-family: 华文行楷;
        font-size: 25px;
        /*绝对定位也行，但是父也不占位。包含块布局的时候一般父相对  父相子绝*/
    }

    #bb {
        width: 200px;
        height: 80px;
        margin: auto;
        line-height: 80px;
    }

    #result {
        width: 400px;
        height: 80px;
        margin: auto;
        line-height: 80px;

    }
</style>
<%--饼图--%>
<div id="show" style="width: 100%;height: 100%; display: none;">
    <div id="result" style="text-align: center"></div>
    <div style="width: 100%;height: 400px;" id="shopping"></div>
    <div style="width: 100%;background-color: rgb(255,99,71)" id="explain"></div>
</div>

<%--数据表格--%>
<table id="demo" lay-filter="test"></table>
</body>
<script>
    layui.config({
        version: 1,
        base: 'echarts/' //这个就是你放Echart.js的目录
    }).use(['table', 'jquery', 'form', 'laydate', 'echarts'], function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery, laydate = layui.laydate, echarts = layui.echarts;

        //第一个实例
        var myTable = table.render({
            elem: '#demo'
            , height: 550
            , url: '${pageContext.request.contextPath}/viewTestResultScl/queryAll.do' //数据接口
            , page: true //开启分页
            , limit: 10
            , limits: [10, 15, 20, 25, 30, 50, 100]
            , toolbar: '#barDemo'
            , cols: [
                [ //表头
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'id', title: 'ID', width: 70, sort: true}
                    , {field: 'name', title: '姓名', width: 100}
                    , {field: 'phone', title: '电话', width: 120}
                    , {field: 'createTime', title: '测试时间', width: 180}

                    , {field: 'somatization', title: '躯体化', width: 130,
                    templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.somatization >= 2.43) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.somatization >= 1.94 && d.somatization < 2.43){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.somatization >= 1.45 && d.somatization < 1.94) || (d.somatization<=1.45 && d.somatization>= 0.96)){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if(d.somatization < 0.96 && d.somatization >= 0.47){
                            '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }

                    }

                    }
                    , {field: 'compel', title: '强迫', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.compel >= 3.27) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.compel >= 2.63  && d.compel < 3.27){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.compel >= 1.99 && d.compel < 2.63) || (d.compel >= 1.35 && d.compel <= 1.99 )){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.compel >= 0.71 && d.compel < 1.35){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }
                    }

                    , {field: 'interpersonal', title: '人际敏感', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.interpersonal >= 3.46) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.interpersonal >= 2.72  && d.interpersonal < 3.46){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.interpersonal >= 1.98 && d.interpersonal < 2.72) || (d.interpersonal >= 1.24 && d.interpersonal <= 1.98 )){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.interpersonal >= 0.5 && d.interpersonal < 1.24){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }
            }


                    , {field: 'depressed', title: '抑郁', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.depressed >= 3.13) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.depressed >= 2.48  && d.depressed < 3.13){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.depressed >= 1.8  && d.depressed < 2.48) || (d.depressed >= 1.18 && d.depressed <= 1.83)){
                            return '<a class="layui-btn layui-btn-normal  layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.depressed >= 0.53 && d.depressed < 1.18){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }
                }

                    , {field: 'anxiety', title: '焦虑', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.depressed >=  2.82) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.depressed >= 2.23 && d.depressed < 2.82){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.depressed >= 1.64  && d.depressed < 2.23) || (d.depressed >= 1.05 && d.depressed <= 1.64 )){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.depressed >= 0.46 && d.depressed < 1.05){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }
                }

                    , {field: 'hostile', title: '敌对', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.hostile >=   3.13) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.hostile >=  2.45 && d.hostile < 3.13){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.hostile >= 1.77  && d.hostile < 2.45) || (d.hostile >= 1.09 && d.hostile <= 1.77 )){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.hostile >= 0.41 && d.hostile < 1.09){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }
                }

                    , {field: 'terror', title: '恐怖', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.terror >=  2.52) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.terror >=1.99 && d.terror < 2.52){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.terror >= 1.46  && d.terror < 1.99) || (d.terror >= 0.93 && d.terror <= 1.46 )){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.terror >=  0.4 && d.terror < 0.93){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }

                }
                    , {field: 'bigoted', title: '偏执', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.bigoted >=  3.23) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.bigoted >= 2.54  && d.bigoted < 3.23 ){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.bigoted >= 1.85  && d.bigoted < 2.54) || (d.bigoted >= 1.16  && d.bigoted <= 1.85  )){
                            return '<a class="layui-btn layui-btn-normal  layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.bigoted >= 0.47 && d.bigoted < 1.16 ){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }

                }
                    , {field: 'psychotic', title: '精神', width: 130

                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.psychotic >  2.71) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.psychotic >= 2.17 && d.psychotic < 2.71){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.psychotic >= 1.63 && d.psychotic < 2.17) || (d.psychotic >= 1.09 && d.psychotic <= 1.63  )){
                            return '<a class="layui-btn layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.psychotic >= 0.55 && d.psychotic < 1.09){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }
                 }
                    , {field: 'sleepanddiet', title: '睡眠及饮食', width: 130
                    ,templet: function (d) {
                        //得到当前行数据，并拼接成自定义模板
                        if (d.sleepanddiet >=  2.33) {
                            //return
                            return '<a class="layui-btn layui-btn-danger  layui-btn-xs">高症状表现</a>'
                        } else if(d.sleepanddiet >= 1.89 && d.sleepanddiet < 2.33){
                            return '<a class="layui-btn  layui-btn-warm layui-btn-xs">较高症状表现</a>'
                        } else if((d.sleepanddiet >= 1.45 && d.sleepanddiet < 1.89) || (d.sleepanddiet >= 1.01 && d.sleepanddiet <= 1.45 )){
                            return '<a class="layui-btn layui-btn-normal layui-btn-xs">中等水平症状表现</a>'
                        }else if (d.sleepanddiet >= 0.57 && d.sleepanddiet <  1.01){
                            return '<a class="layui-btn  layui-btn-xs">较低症状表现</a>'
                        }else {
                            return '<a class="layui-btn  layui-btn-xs">低症状表现</a>'
                        }
                    }

                }

                   /* , {field: 'testPlanId', title: '测试计划ID', width: 120, sort: true}*/
                    , {field: 'testName', title: '测试计划', width: 120, sort: true}
                    , {fixed: 'right', title: '操作', width: 300, align: 'center', toolbar: '#rowBarDemo'}
                ]
            ]
        });
        /*
        *
        * 行内工具栏
        * */
        //监听行工具事件
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                //console.log(data)
                , layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'check') {
                //layer.msg('查看操作');
                //弹出层
                layer.open({
                    title: '抑郁测试结果图示',
                    type: 1,
                    content: $('#show'), //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                    area: ['600px', '600px']
                });
                $.ajax({
                    url: "${pageContext.request.contextPath}/viewTestResultScl/queryAllById.do",
                    type: "POST",
                    dataType: "JSON",
                    data: {id: obj.data.id},
                    area: ['900px', '900px'],
                    success: function (ret) {
                        var a = data.somatization
                        var b = data.compel
                        var c = data.interpersonal
                        var d = data.depressed
                        var e = data.anxiety
                        var f = data.hostile
                        var g = data.terror
                        var h = data.bigoted
                        var i = data.psychotic
                        var j = data.sleepanddiet
                        var myChart = echarts.init(document.getElementById('shopping'));
                        var option;
                        var string = "你的结果如下";
                        $("#result").html(string)
                        option = {
                            color: [
                                '#c23531',
                                '#2f4554',
                                '#61a0a8',
                                '#d48265',
                                '#91c7ae',
                                '#749f83',
                                '#ca8622',
                                '#bda29a',
                                '#6e7074',
                                '#546570',
                                '#c4ccd3'
                            ],
                            title: {
                                text: 'SCL心理健康测试',
                                left: 'center'
                            },
                            tooltip: {
                                trigger: 'item'
                            },
                            legend: {
                                data: ['你的得分','正常值'],
                                left: 'left'
                            },
                            radar: {
                                indicator: [
                                    { name: '躯体化', max: 5 },
                                    { name: '强迫', max: 5 },
                                    { name: '人际敏感', max: 5 },
                                    { name: '抑郁', max:5},
                                    { name: '焦虑', max: 5 },
                                    { name: '敌对性', max: 5 },
                                    { name: '恐怖', max: 5},
                                    { name: '偏执', max: 5 },
                                    { name: '精神病性', max: 5 },
                                    { name: '睡眠及饮食', max: 5 }
                                ]
                            },
                            series: [
                                {
                                    name: 'SCL得分',
                                    type: 'radar',//雷达图类型
                                    data: [
                                        {
                                            value: [a, b, c, d, e, f , g , h , i , j],
                                            name: '你的得分'
                                        },
                                        {
                                            value: [1.45, 1.99, 1.98, 1.83, 1.64, 1.77 , 1.46 , 1.85, 1.63,1.45 ],
                                            name: '正常值'
                                        }
                                    ]
                                }
                            ]
                        };
                        option && myChart.setOption(option);
                        var htmlStr = "";
                        if (a > 2.43) {
                            htmlStr += "<div><h3 align='center'>躯体化：高症状表现</h3></div>"
                        }
                        if (a < 0.47) {
                            htmlStr += "<div><h3 align='center'>躯体化：低症状表现</h3></div>"
                        }
                        if (a > 1.94 && a < 2.43) {
                            htmlStr += "<div><h3 align='center'>躯体化：较高症状表现</h3></div>"
                        }
                        if (a < 0.96 && a > 0.47) {
                            htmlStr += "<div><h3 align='center'>躯体化：较低症状表现</h3></div>"
                        }
                        if ((a > 1.45 && a < 1.94) || (a<1.45 && a> 0.96)) {
                            htmlStr += "<div><h3 align='center'>躯体化：中等水平症状表现</h3></div>"
                        }
                        if (b > 3.27) {
                            htmlStr += "<div><h3 align='center'>强迫：高症状表现</h3></div>"
                        }
                        if (b < 0.71) {
                            htmlStr += "<div><h3 align='center'>强迫：低症状表现</h3></div>"
                        }
                        if (b > 2.63 && b < 3.27) {
                            htmlStr += "<div><h3 align='center'>强迫：较高症状表现</h3></div>"
                        }
                        if (b < 1.35 && b > 0.71) {
                            htmlStr += "<div><h3 align='center'>强迫：较低症状表现</h3></div>"
                        }
                        if ((b > 1.99 && b < 2.63) || (b<1.99 && b> 1.35)) {
                            htmlStr += "<div><h3 align='center'>强迫：中等水平症状表现</h3></div>"
                        }
                        if (c > 3.46) {
                            htmlStr += "<div><h3 align='center'>人际敏感：高症状表现</h3></div>"
                        }
                        if (c < 0.5) {
                            htmlStr += "<div><h3 align='center'>人际敏感：低症状表现</h3></div>"
                        }
                        if (c > 2.72 && c < 3.46) {
                            htmlStr += "<div><h3 align='center'>人际敏感：较高症状表现</h3></div>"
                        }
                        if (c < 1.24 && c > 0.5) {
                            htmlStr += "<div><h3 align='center'>人际敏感：较低症状表现</h3></div>"
                        }
                        if ((c > 1.98 && c < 2.72) || (c<1.98 && c > 1.24)) {
                            htmlStr += "<div><h3 align='center'>人际敏感：中等水平症状表现</h3></div>"
                        }
                        if (d > 3.13) {
                            htmlStr += "<div><h3 align='center'>抑郁：高症状表现</h3></div>"
                        }
                        if (d < 0.53) {
                            htmlStr += "<div><h3 align='center'>抑郁：低症状表现</h3></div>"
                        }
                        if (d > 2.48 && d < 3.13) {
                            htmlStr += "<div><h3 align='center'>抑郁：较高症状表现</h3></div>"
                        }
                        if (d < 1.18 && d > 0.53) {
                            htmlStr += "<div><h3 align='center'>抑郁：较低症状表现</h3></div>"
                        }
                        if ((d > 1.8 && d < 2.48) || (d <1.83 && d > 1.18)) {
                            htmlStr += "<div><h3 align='center'>抑郁：中等水平症状表现</h3></div>"
                        }
                        if (e > 2.82) {
                            htmlStr += "<div><h3 align='center'>焦虑：高症状表现</h3></div>"
                        }
                        if (e < 0.46) {
                            htmlStr += "<div><h3 align='center'>焦虑：低症状表现</h3></div>"
                        }
                        if (e > 2.23 && e < 2.82) {
                            htmlStr += "<div><h3 align='center'>焦虑：较高症状表现</h3></div>"
                        }
                        if (e < 1.05 && e > 0.46) {
                            htmlStr += "<div><h3 align='center'>焦虑：较低症状表现</h3></div>"
                        }
                        if ((e > 1.64 && e < 2.23) || (e <1.64 && e > 1.05)) {
                            htmlStr += "<div><h3 align='center'>焦虑：中等水平症状表现</h3></div>"
                        }
                        if (f > 3.13) {
                            htmlStr += "<div><h3 align='center'>敌对：高症状表现</h3></div>"
                        }
                        if (f < 0.41) {
                            htmlStr += "<div><h3 align='center'>敌对：低症状表现</h3></div>"
                        }
                        if (f > 2.45 && f < 3.13) {
                            htmlStr += "<div><h3 align='center'>敌对：较高症状表现</h3></div>"
                        }
                        if (f < 1.09 && f > 0.41) {
                            htmlStr += "<div><h3 align='center'>敌对：较低症状表现</h3></div>"
                        }
                        if ((f > 1.77 && f < 2.45) || (f <1.77 && f > 1.09)) {
                            htmlStr += "<div><h3 align='center'>敌对：中等水平症状表现</h3></div>"
                        }
                        if (g > 2.52) {
                            htmlStr += "<div><h3 align='center'>恐怖：高症状表现</h3></div>"
                        }
                        if (g < 0.4) {
                            htmlStr += "<div><h3 align='center'>恐怖：低症状表现</h3></div>"
                        }
                        if (g > 1.99 && g < 2.52) {
                            htmlStr += "<div><h3 align='center'>恐怖：较高症状表现</h3></div>"
                        }
                        if (g < 0.93 && g > 0.4) {
                            htmlStr += "<div><h3 align='center'>恐怖：较低症状表现</h3></div>"
                        }
                        if ((g > 1.46 && g < 1.99) || (g <1.46 && g > 0.93)) {
                            htmlStr += "<div><h3 align='center'>恐怖：中等水平症状表现</h3></div>"
                        }
                        if (h > 3.23) {
                            htmlStr += "<div><h3 align='center'>偏执：高症状表现</h3></div>"
                        }
                        if (h < 0.47) {
                            htmlStr += "<div><h3 align='center'>偏执：低症状表现</h3></div>"
                        }
                        if (h > 2.54 && h < 3.23) {
                            htmlStr += "<div><h3 align='center'>偏执：较高症状表现</h3></div>"
                        }
                        if (h < 1.16 && h > 0.47) {
                            htmlStr += "<div><h3 align='center'>偏执：较低症状表现</h3></div>"
                        }
                        if ((h > 1.85 && h < 2.54) || (h <1.85 && h > 1.16)) {
                            htmlStr += "<div><h3 align='center'>偏执：中等水平症状表现</h3></div>"
                        }
                        if (i > 2.71) {
                            htmlStr += "<div><h3 align='center'>精神病性：高症状表现</h3></div>"
                        }
                        if (i < 0.55) {
                            htmlStr += "<div><h3 align='center'>精神病性：低症状表现</h3></div>"
                        }
                        if (i > 2.17 && i < 2.71) {
                            htmlStr += "<div><h3 align='center'>精神病性：较高症状表现</h3></div>"
                        }
                        if (i < 1.09 && i > 0.55) {
                            htmlStr += "<div><h3 align='center'>精神病性：较低症状表现</h3></div>"
                        }
                        if ((i > 1.63 && i < 2.17) || (i <1.63 && i > 1.09)) {
                            htmlStr += "<div><h3 align='center'>精神病性：中等水平症状表现</h3></div>"
                        }
                        if (j > 2.33) {
                            htmlStr += "<div><h3 align='center'>睡眠及饮食：高症状表现</h3></div>"
                        }
                        if (j < 0.57) {
                            htmlStr += "<div><h3 align='center'>睡眠及饮食：低症状表现</h3></div>"
                        }
                        if (j > 1.89 && j < 2.33) {
                            htmlStr += "<div><h3 align='center'>睡眠及饮食：较高症状表现</h3></div>"
                        }
                        if (j < 1.01 && j > 0.57) {
                            htmlStr += "<div><h3 align='center'>睡眠及饮食：较低症状表现</h3></div>"
                        }
                        if ((j > 1.45 && j < 1.89) || (j <1.45 && j > 1.01)) {
                            htmlStr += "<div><h3 align='center'>睡眠及饮食：中等水平症状表现</h3></div>"
                        }
                        $("#explain").html(htmlStr);

                        option = {
                            legend: {
                                top: 'bottom'
                            },
                            toolbox: {
                                show: true,
                                feature: {
                                    mark: { show: true },
                                    dataView: { show: true, readOnly: false },
                                    restore: { show: true },
                                    saveAsImage: { show: true }
                                }
                            },
                            series: [
                                {
                                    name: 'Nightingale Chart',
                                    type: 'pie',
                                    radius: [50, 100],
                                    center: ['50%', '50%'],
                                    roseType: 'area',
                                    itemStyle: {
                                        borderRadius: 8
                                    },
                                    data: [
                                        { value: somatization, name: '躯体化' },
                                        { value: compel, name: '强迫' },
                                        { value: interpersonal, name: ' 人际敏感' },
                                        { value: depressed, name: ' 抑郁' },
                                        { value: anxiety, name: '焦虑 ' },
                                        { value: hostile, name: ' 敌对' },
                                        { value: terror, name: '恐怖 ' },
                                        { value: bigoted, name: ' 偏执' },
                                        { value: psychotic, name: ' 精神' },
                                        { value: sleepanddiet, name: ' 睡眠及饮食' }
                                    ]
                                }
                            ]
                        };


                        // 使用刚指定的配置项和数据显示图表。
                        myChart.setOption(option);
                    }
                })

            } else if (obj.event === 'del') {
                layer.confirm('您真的删除行么', function (index) {
                    // 删除用户信息
                    $.ajax({
                        url: '${pageContext.request.contextPath}/viewTestResultScl/deleteResultSds.do',
                        type: 'POST',
                        dataType: 'JSON',
                        data: {testerId: data.id},
                        success: function (data) {
                            if (data.code == 0) {
                                // 关闭对话框
                                layer.closeAll();
                                // 刷新表格数据
                                table.reload('demo');
                            }
                            layer.msg(data.msg);
                        }
                    });
                });
            } else if (obj.event === 'result'){

                //弹出答案框
                layer.open({
                    type: 1
                    , title: '答案'
                    , content: $('#addForm') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                    , offset: '50px'
                    , area: ['800px', '600px']
                });

                table.render({
                    elem: '#clickResult'
                    ,height: 500
                    ,url: '${pageContext.request.contextPath}/viewTestResultScl/queryTestResultById.do?testerId='+data.id //数据接口
                    ,page: true //开启分页
                    , limit: 10
                    , limits: [10, 15, 20, 25, 30, 50, 100]
                    ,cols: [[ //表头
                        {field: 'questionId', title: '题号', width:100, sort: true, fixed: 'left'}
                        ,{field: 'testerId', title: '测试者id', width:120}
                        ,{field: 'question', title: '问题', width:420, sort: true}
                        ,{field: 'answer', title: '回答', width:80
                            ,templet: function (d) {
                                //得到当前行数据，并拼接成自定义模板
                                if (d.answer ===  1) {
                                    //return
                                    return '<a class="layui-btn  layui-btn-danger layui-btn-xs">A</a>'
                                } else if(d.answer === 2){
                                    return '<a class="layui-btn layui-btn-warm layui-btn-xs">B</a>'
                                } else if(d.answer === 3){
                                    return '<a class="layui-btn  layui-btn-normal layui-btn-xs">C</a>'
                                }else if (d.answer === 4 ){
                                    return '<a class="layui-btn  layui-btn-xs">D</a>'
                                }else if (d.answer === 5 ){
                                    return '<a class="layui-btn  layui-btn-xs">E</a>'
                                }else {
                                    return '<a class="layui-btn  layui-btn-xs">错误选项</a>'
                                }
                            }
                        }
                    ]]
                });


            }
           /* else if (obj.event === 'result2'){
                form.val("returnRecord", {
                    "testerId": data.id
                    , "testName": data.testName
                    , "testerName": data.name
                    , "phone": data.phone
                    , "remark": data.remark
                });
                layer.open({//弹出修改框
                    title: '添加回访记录',
                    type: 1,
                    content: $("#returnRecord"),
                    area: ('400px', '360px')
                });


            }*/
        });
        //监听头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'delete':
                    if (data.length === 0) {
                        layer.msg('请选择一行');
                    } else {
                        layer.confirm('真的删除选中的行么', function (index) {
                            //obj.del(); //删除对应行（tr）的DOM结构
                            //删除数据库中的数据
                            var idList = [];
                            //遍历数组data，抽取所有的id
                            for (let i = 0; i < data.length; i++) {
                                idList[i] = (data[i].id);
                            }
                            $.ajax({
                                url: "${pageContext.request.contextPath}/viewTestResultScl/deleteResultSds.do",
                                type: "POST",
                                dataType: "JSON",
                                data: {testerId: idList.join(",")},
                                success: function (ret) {
                                    if (ret.code == 0) {
                                        //刷新表格数据
                                        myTable.reload({
                                            page: {
                                                curr: 1 //重新从第 1 页开始
                                            }
                                        });
                                        layer.msg(ret.msg, {icon: 6});
                                    } else {
                                        layer.msg(ret.msg, {icon: 5});
                                    }
                                }
                            })
                            layer.close(index);
                            //向服务端发送删除指令
                        });
                    }
                    break;
            }
        })

        //================提交条件查询=========
        form.on('submit(selectFormfilter)', function (data) {
            //console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            //提交表单数据
            myTable.reload({
                where: { //设定异步数据接口的额外参数，任意设
                    name: data.field.name
                    , testName: data.field.testName
                    , studentType: data.field.studentType
                }
                ,
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        ///重置条件查询表单，刷新table数据
        $("#myButton").click(function () {
            myTable.reload({
                where: { //设定异步数据接口的额外参数，任意设
                    name: ""
                    , testPlanId: ""
                    , studentType: ""
                    //…
                }
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        })
    })
</script>
</html>
